<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>tView</title>
	<link rel="stylesheet" type="text/css" href="styles/screen.css" media="screen" />
	<script src="js/prototype.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div id="head">
		<div id="logo">
			<h1>tView<sup style="font-size: 10px;">v<?= tView_Config::$tViewVersion ?></sup></h1>
			<p>PHPUnit reports viewer</p>
		</div>
		<div id="options">
		</div>
		<div style="clear: both;"></div>
	</div>
	<div id="main">
		<div id="resultsView">
			<div style="float: left;">
				<h2 id="testSuite"><?= $tView->getName() ?></h2>
				<span id="testFile"><?= tView_Config::$xmlFile ?></span>
			</div>
			<div style="float: right;">
				<div style="margin-bottom: 5px; width: 320px; height: 20px;">
					<?= $tView->renderBar() ?>
				</div>
				<span><?= $tView->getCount() ?></span> test suites in <span><?= $tView->getTime() ?></span> seconds
			</div>
			<div style="clear: both;"></div>

		<?php if ($tView->getFailedCount() > 0) : ?>
			<br />
			<h3>Failed (<?= $tView->getFailedCount() ?>)</h3>
			<div id="failed">
				<table cellspacing="0" class="testingResults">
					<thead>
						<tr>
							<th>Name</th>
							<th>Test Case</th>
						</tr>
					</thead>
					<tbody>
			<?php 
				foreach ($tView->getFailed() as $suite) {
					$failedTestCases = $suite->getFailedTestCases();
					$count = count($failedTestCases);
					
					$xhtml = '<tr><td rowspan="' . $count . '">' 
						. $suite->getName() . '</td>';
					$i = 1;
					foreach ($failedTestCases as $failed) {
						$failure = $failed->getFailure();
						if ($i > 1) {
							$xhtml .= '<tr>';
						}
						$xhtml .= '<td><pre>' . $failure->getText() 
							. '</pre></td></tr>';
						$i++;
					}
					echo $xhtml;
				}
			?>
					</tbody>
				</table>
			</div>
		<?php endif; ?>

		<?php if ($tView->getErrorCount() > 0) : ?>
			<br />
			<h3>Error (<?= $tView->getErrorCount() ?>)</h3>
			<div id="error">
			<?php foreach ($tView->getError() as $suite) : ?>
				<?= $suite->getName() ?>
			<?php endforeach; ?>
			</div>
		<?php endif; ?>

		<?php if ($tView->getEmptyCount() > 0) : ?>
			<br />
			<h3>Empty (<?= $tView->getEmptyCount() ?>)</h3>
			<div id="empty">
				<table cellspacing="0" class="testingResults">
					<thead>
						<tr>
							<th>Name</th>
							<th>File</th>
						</tr>
					</thead>
					<tbody>
			<?php foreach ($tView->getEmpty() as $suite) : ?>
						<tr>
							<td><?= $suite->getName() ?></td>
							<td><?= $suite->getFile() ?></td>
						</tr>
			<?php endforeach; ?>
					</tbody>
				</table>
			</div>
		<?php endif; ?>

		<?php if ($tView->getPassedCount() > 0) : ?>
			<br />
			<h3>Passed (<?= $tView->getPassedCount() ?>)</h3>
			<div id="passed">
				<table class="testingResults" cellspacing="0">
					<thead>
						<tr>
							<th>Name</th>
							<th>File</th>
							<th>Tests</th>
							<th>Assertions</th>
							<th>Time</th>
						</tr>
					</thead>
					<tbody>
				<?php foreach ($tView->getPassed() as $suite) : ?>
						<tr>
							<td><?= $suite->getName() ?></td>
							<td><?= $suite->getFile() ?></td>
							<td><?= $suite->getCount() ?></td>
							<td><?= $suite->getAssertions() ?></td>
							<td><?= $suite->getTime() ?></td>
						</tr>
				<?php endforeach; ?>
					</tbody>
				</table>
			</div>
		<?php endif; ?>

		</div>
	</div>
	<div id="footer">
	<?php if (tView_Config::$checkVersion) : ?>
		<div id="versionInfo">&nbsp;</div>
	<?php endif; ?>
		<p>Copyright &copy; 2009 Vitaly Shlyaga. <a href="http://code.google.com/p/tview/">tView homepage</a>.</p>
	</div>

	<script type="text/javascript">
		$$('table.testingResults tbody > tr:nth-child(even)').each(function(s) {
			s.addClassName('even');
		});	
	</script>

</body>
</html>
